**Do-File DK2014 - NY

*Importing data-file
use Data2014ref

*Sort by panel ID and dropping respondents who don't have a panel ID
sort responseid

*Dropping respondents who have not participated in both Waves and who were exposed to policy as part of an experiment
codebook WaveNr
drop if WaveNr==.

codebook WaveNr_W2
drop if WaveNr_W2==.

codebook frameexp
drop if frameexp==4


******Cleaning data before reshaping to long format******
codebook koen alder sidstuddan_ds region  erhverv q3d q3b q4_1 q6 q8 q9_2 q12_2 q12_3 q12_4 q13_1 q13_2 q13_3 q13_4 q13_5 q13_6 q13_7 q13_8 q14_2 q15 q16a q16b  q17 q22 q23_5 q23_7 q23_8 q24 q25 q26_10 q26_11 q26_17 q26_22 q27 WaveNr Q6W2 Q8W2 Q9W2_2_slice Q12W2_2_slice Q12W2_3_slice Q12W2_4_slice Q13W2_1_slice Q13W2_2_slice Q13W2_3_slice Q13W2_4_slice Q13W2_5_slice Q13W2_6_slice Q13W2_7_slice Q13W2_8_slice Q15W2 Q16aW2 Q16bW2 Q17W2 Q22W2 Q23W21 Q23W22 Q23W23 Q24W2 Q25W2 Q26W210 Q26W211 Q26W217 Q26W222 Q27W2 WaveNr_W2 frameexp, tab(99)

keep responseid interview_end koen alder sidstuddan_ds region  erhverv q3d q3b q4_1 q6 q8 q9_2 q12_2 q12_3 q12_4 q13_1 q13_2 q13_3 q13_4 q13_5 q13_6 q13_7 q13_8 q14_2 q15 q16a q16b q17 q22 q23_5 q23_7 q23_8 q24 q25 q26_10 q26_11 q26_17 q26_22 q27 WaveNr Q6W2 Q8W2 Q9W2_2_slice Q12W2_2_slice Q12W2_3_slice Q12W2_4_slice Q13W2_1_slice Q13W2_2_slice Q13W2_3_slice Q13W2_4_slice Q13W2_5_slice Q13W2_6_slice Q13W2_7_slice Q13W2_8_slice Q15W2 Q16aW2 Q16bW2 Q17W2 Q22W2 Q23W21 Q23W22 Q23W23 Q24W2 Q25W2 Q26W210 Q26W211 Q26W217 Q26W222 Q27W2 WaveNr_W2 frameexp

rename q6 q6_pre
rename q8 q8_pre
rename q9_2 q9_2_pre
rename q12_2 q12_2_pre
rename q12_3 q12_3_pre
rename q12_4 q12_4_pre
rename q13_1 q13_1_pre
rename q13_2 q13_2_pre
rename q13_3 q13_3_pre
rename q13_4 q13_4_pre
rename q13_5 q13_5_pre
rename q13_6 q13_6_pre
rename q13_7 q13_7_pre
rename q13_8 q13_8_pre
rename q15 q15_pre
rename q16a q16a_pre
rename q16b q16b_pre
rename q17 q17_pre
rename q22 q22_pre
rename q23_5 q23_5_pre
rename q23_7 q23_7_pre
rename q23_8 q23_8_pre
rename q24 q24_pre
rename q25 q25_pre
rename q26_10 q26_10_pre
rename q26_11 q26_11_pre
rename q26_17 q26_17_pre
rename q26_22 q26_22_pre
rename q27 q27_pre

rename Q6W2 q6_post
rename Q8W2 q8_post
rename Q9W2_2_slice q9_2_post
rename Q12W2_2_slice q12_2_post
rename Q12W2_3_slice q12_3_post
rename Q12W2_4_slice q12_4_post
rename Q13W2_1_slice q13_1_post
rename Q13W2_2_slice q13_2_post
rename Q13W2_3_slice q13_3_post
rename Q13W2_4_slice q13_4_post
rename Q13W2_5_slice q13_5_post
rename Q13W2_6_slice q13_6_post
rename Q13W2_7_slice q13_7_post
rename Q13W2_8_slice q13_8_post
rename Q15W2 q15_post
rename Q16aW2 q16a_post
rename Q16bW2 q16b_post
rename Q17W2 q17_post
rename Q22W2 q22_post
rename Q23W21 q23_5_post
rename Q23W22 q23_7_post
rename Q23W23 q23_8_post
rename Q24W2 q24_post
rename Q25W2 q25_post
rename Q26W210 q26_10_post
rename Q26W211 q26_11_post
rename Q26W217 q26_17_post
rename Q26W222 q26_22_post
rename Q27W2 q27_post

*Dropping respondents who have not not provided follow-up answers to their policy opinion or perception of policy info 
drop if q8_post==.
drop if q12_4_post==.

*Recoding knowledge variables
codebook q23_5_pre q23_7_pre q23_8_pre q23_5_post q23_7_post q23_8_post, tab(99)
recode q23_5_post (5 7 8=1 "London, Munchen eller Paris") (1 2 3 4 6 9 12 13 .=0), gen(q23_5_post1)
codebook q23_5_post q23_5_post1, tab(99)
drop q23_5_post
rename q23_5_post1 q23_5_post
codebook q23_5_post

recode q23_7_post (5 7 8=1 "London, Munchen eller Paris") (2 3 4 6 9 10 11 12 .=0), gen(q23_7_post1)
codebook q23_7_post q23_7_post1, tab(99)
drop q23_7_post
rename q23_7_post1 q23_7_post
codebook q23_7_post

recode q23_8_post (5 7 8=1 "London, Munchen eller Paris") (6 9 10 11 12 .=0), gen(q23_8_post1)
codebook q23_8_post q23_8_post1, tab(99)
drop q23_8_post
rename q23_8_post1 q23_8_post
codebook q23_8_post


**********Reshaping data from wide to long format to prepare for analysis************
reshape long q6 q8 q9_2 q12_2 q12_3 q12_4 q13_1 q13_2 q13_3 q13_4 q13_5 q13_6 q13_7 q13_8 q15 q16a q16b q17 q22 q23_5 q23_7 q23_8 q24 q25 q26_10 q26_11 q26_17 q26_22 q27, i(responseid) j(time) string



*Creating a time dummy variable indicating whether respondents answered before or after the campaign
codebook time
encode time, gen(time1)
codebook time1
recode time1 (1=1 "Wave 2") (2=0 "Wave 1"), gen(timedummy)
codebook timedummy



*******Creating dependent variable (policy opinion: inclination to vote NO): ********
codebook q8
recode q8 (1 2 5=0 "YES (in favour of proposal including don't knows)") (3 4=1 "NO (in opposition to proposal"), gen(vote_no)
codebook q8 vote_no



**********Creating learning variable (independent variable)*********


*Perception whether Denmark will lose national sovereignty if voting yes and joining the common patent court
codebook q12_4
recode q12_4 (1 2 6=0 "Uninformed") (3 4 5=1 "Correctly Informed"), gen(nat_sov_perception)
codebook nat_sov_perception

gen learn_policyinfo=.
sort responseid timedummy
by responseid (timedummy), sort: replace learn_policyinfo=0 if nat_sov_perception[_n-1]==0 & (nat_sov_perception==0)
by responseid (timedummy), sort: replace learn_policyinfo=1 if nat_sov_perception[_n-1]==0 & (nat_sov_perception==1)
by responseid (timedummy), sort: replace learn_policyinfo=2 if nat_sov_perception[_n-1]==1 & (nat_sov_perception==1)
by responseid (timedummy), sort: replace learn_policyinfo=3 if nat_sov_perception[_n-1]==1 & (nat_sov_perception==0)
label define learn_policyinfo 0 "Never Learned" 1 "Learned Policy Info" 2 "Already Knew" 3 "Forgot"
label values learn_policyinfo learn_policyinfo
codebook learn_policyinfo

bro responseid timedummy learn_policyinfo nat_sov_perception

*Adding values to misssing observation regarding independent variable (learning)
bysort responseid (timedummy) : replace learn_policyinfo = learn_policyinfo[_n+1] if missing(learn_policyinfo)

*Checking coding was made correct
bro responseid timedummy nat_sov_perception learn_policyinfo
tab timedummy learn_policyinfo, row




************************Control Variables************************



*******Time-invariant background variables - used for matching and control for unispecific time-trends********

*Gender
codebook koen
recode koen (1=1 "Male") (2=2 "Female"), gen(gender)
codebook gender
tab timedummy gender, row

*Age
codebook alder, tab(99)
rename alder age

gen age_cat=.
replace age_cat=1 if inrange(age, 17, 29.1)
replace age_cat=2 if inrange(age, 29.9, 39.1)
replace age_cat=3 if inrange(age, 39.9, 49.1)
replace age_cat=4 if inrange(age, 49.9, 59.1)
replace age_cat=5 if inrange(age, 59.9, 70.1)

label define age_cat 1 "18-29" 2 "30-39" 3 "40-49" 4 "50-59" 5 "60+"
label values age_cat age_cat
codebook age_cat

*Education
codebook sidstuddan_ds, tab(99)
recode sidstuddan_ds (4=2 "Vocational school") (1=1 "Elementary school") (2 3=3 "High school") (5=4 "Higher education, short") (7 6=5 "Higher education, middle") (8 9=6 "Higher education, long") (10=7 "Don't know (will not like to answer)"), gen(education)
codebook sidstuddan_ds education, tab(99)


*Occupation
codebook erhverv, tab(99)
recode erhverv (1 2=1 "Unskilled worker") (3=2 "Skilled worker") (4 5=3 "White-collar worker") (6 7 8=4 "Self-employed") (9 10=5 "Student") (11=6 "Retired") (12 14=7 "Unemployed"), gen(occupation)
codebook erhverv occupation


*Region of residence
codebook region
recode region (1=1 "Copenhagen") (2=2 "Zealand") (3=3 "South Denmark") (4=4 "Mid-Jutland") (5=5 "North Jutland"), gen(region1)
codebook region region1
drop region
rename region1 region
tab timedummy region, row



*Partisanship - measured in wave 1 (used for analysis where I restrict the pool to only include voters who support a party recommending voting in favour of the referendum proposal)
codebook q3b q3d, tab(99)
gen prior_partisanship=0
replace prior_partisanship=1 if q3b==1 | q3b==2 | q3b==3 | q3b==4 | q3b==5 | q3b==6 | q3b==8
replace prior_partisanship=1 if q3d==1 | q3d==2 | q3d==3 | q3d==4 | q3d==5 | q3d==6 | q3d==8
replace prior_partisanship=2 if q3b==7 | q3b==9 
replace prior_partisanship=2 if q3d==7 | q3d==9 
codebook q3b q3d prior_partisanship, tab(99)
tab timedummy prior_partisanship, row

label define prior_partisanship 0 "No party affiliation" 1 "Support party recommending a YES" 2 "Support party recommending a NO"
label values prior_partisanship prior_partisanship
codebook prior_partisanship

*Prior ideological self-placement (used for matching)
codebook q4_1, tab(99)
recode q4_1 (1=0 "Left") (2=1) (3=2) (4=3) (5=4) (6 12=5) (7=6) (8=7) (9=8) (10=9) (11=10 "Right"), gen(prior_ideology)
codebook q4_1 prior_ideology, tab(99)
tab timedummy prior_ideology, row 

*Prior EU values - measured in Wave 1 (used for matching)
codebook q15
gen prior_EU_attitude=q15 if timedummy==0
bysort responseid (timedummy) : replace prior_EU_attitude = prior_EU_attitude[_n-1] if missing(prior_EU_attitude)
codebook q15 prior_EU_attitude if timedummy==0
recode prior_EU_attitude (1=5 "Very positive (towards EU)") (2=4 "Predominantly positive") (3 6=3 "Neither nor (including don't knows)") (4=2 "Predominantly negative") (5=1 "Very negative (towards EU)") , gen(prior_EU_attitude1)
codebook prior_EU_attitude1 q15 if timedummy==0
drop prior_EU_attitude
rename prior_EU_attitude1 prior_EU_attitude
tab timedummy prior_EU_attitude, row




*********Time-varying control variables********


*Perceived government performance
codebook q17
recode q17 (1=7 "Very good") (2=6 "Good") (3=5 "Predominantly good") (4 8=4 "Neither good nor bad (including don't knows)") (5=3 "Predominantly good") (6=2 "Bad") (7=1 "Very bad"), gen(perceived_governmentperformance)
codebook q17 perceived_governmentperformance

*Interest in EU politics (attention paid to EU debate)
codebook q22
recode q22 (1=4 "Followed debate really closely") (2=3 "Followed debate closely") (3=2 "Have not followed debate that closely") (4=1 "Have not followed debate at all") (5=.), gen(followed_debate)
codebook q22 followed_debate


*Knowledge of the Patent Court (index construction)
codebook q23_5 q23_7 q23_8
gen knowledge1=0 
replace knowledge1=1 if q23_5==1
replace knowledge1=1 if q23_7==1
replace knowledge1=1 if q23_8==1
codebook knowledge1
label define knowledge1 0 "Incorrect answer" 1 "Correct answer"
label values knowledge1 knowledge1
codebook knowledge1

codebook q24
recode q24 (2=1 "Correct answer") (1 3=0 "Incorrect answer"), gen(knowledge2)
codebook knowledge2

codebook q25
recode q25 (1=1 "Correct answer") (2 3=0 "Incorrect answer"), gen(knowledge3)
codebook knowledge3

codebook q26_10 q26_11 q26_17 q26_22, tab(99)
gen knowledge4=0 
replace knowledge4=1 if q26_10==1
replace knowledge4=1 if q26_11==1
replace knowledge4=1 if q26_17==1
replace knowledge4=1 if q26_22==1
codebook knowledge4
label define knowledge4 0 "Incorrect answer" 1 "Correct answer"
label values knowledge4 knowledge4
codebook knowledge4

codebook q27
recode q27 (1=1 "Correct answer") (2 3=0 "Incorrect answer"), gen(knowledge5)
codebook knowledge5

pwcorr knowledge1 knowledge2 knowledge3 knowledge4 knowledge5
alpha knowledge1 knowledge2 knowledge3 knowledge4 knowledge5, item min(3)
alpha knowledge1 knowledge2 knowledge3 knowledge4 knowledge5, gen(knowledge_index) min(3)
hist knowledge_index
sum knowledge_index
codebook knowledge_index, tab(99)
recode knowledge_index (0=0 "0 answers corrects") (0.2=1 "1 answer correct") (0.40000001=2 "2 answers correct") (0.60000002=3 "3 answers correct") (0.80000001=4 "4 answers correct") (1=5 "5 answers correct"), gen(knowledge)
codebook knowledge_index knowledge, tab(99)
drop knowledge_index


*Issue attitude 1 - Big multinational companies will take patent on genes and computersoftware
codebook q12_2 
recode q12_2 (1 2 6=0 "Do not think it is likely") (3 4 5=1 "Think it is likely"), gen(issueattitude1)
codebook q12_2 issueattitude1


*Issue attitude 2 - It will become cheaper for danish companies to get patent protection
codebook q12_3 
recode q12_3 (1 2 6=0 "Do not think it is likely") (3 4 5=1 "Think it is likely"), gen(issueattitude2)
codebook q12_3 issueattitude2


****Learning your party's position (vote recommendation)


*Parti-ID
codebook q3b q3d, tab(99)

gen parti_id=.
replace parti_id=1 if q3b==1 | q3d==1
replace parti_id=2 if q3b==2 | q3d==2
replace parti_id=3 if q3b==3 | q3d==3
replace parti_id=4 if q3b==4 | q3d==4
replace parti_id=5 if q3b==5 | q3d==5
replace parti_id=6 if q3b==6 | q3d==6
replace parti_id=7 if q3b==7 | q3d==7
replace parti_id=8 if q3b==8 | q3d==8
replace parti_id=9 if q3b==9 | q3d==9
label define parti_id 1 "Socialdemokraterme" 2 "Radikale Venstre" 3 "Det Konservative Folkeparti" 4 "SF" 5 "Liberal Alliance" 6 "Kristendemokraterne" 7 "Dansk Folkeparti" 8 "Venstre" 9 "Enhedslisten"
label values parti_id parti_id
codebook parti_id

*Knowledge of party's positions on referendum issue

codebook q13_1 q13_2 q13_3 q13_4 q13_5 q13_6 q13_7 q13_8
recode q13_1 (1=1 "Know the correct party position") (2 3=0 "Don't know the correct party position"), gen(partyposition_S)
recode q13_2 (1=1 "Know the correct party position") (2 3=0 "Don't know the correct party position"), gen(partyposition_RV)
recode q13_3 (1=1 "Know the correct party position") (2 3=0 "Don't know the correct party position"), gen(partyposition_K)
recode q13_4 (1=1 "Know the correct party position") (2 3=0 "Don't know the correct party position"), gen(partyposition_SF)
recode q13_5 (1=1 "Know the correct party position") (2 3=0 "Don't know the correct party position"), gen(partyposition_LA)
recode q13_6 (2=1 "Know the correct party position") (1 3=0 "Don't know the correct party position"), gen(partyposition_DF)
recode q13_7 (1=1 "Know the correct party position") (2 3=0 "Don't know the correct party position"), gen(partyposition_V)
recode q13_8 (2=1 "Know the correct party position") (1 3=0 "Don't know the correct party position"), gen(partyposition_EL)
codebook partyposition_S partyposition_RV partyposition_K partyposition_SF partyposition_LA partyposition_DF partyposition_V partyposition_EL

*Matching party supporters with knowledge of their positions

gen know_own_partyposition=.

replace know_own_partyposition=0 if parti_id==1 & partyposition_S==0
replace know_own_partyposition=0 if parti_id==2 & partyposition_RV==0
replace know_own_partyposition=0 if parti_id==3 & partyposition_K==0
replace know_own_partyposition=0 if parti_id==4 & partyposition_SF==0
replace know_own_partyposition=0 if parti_id==5 & partyposition_LA==0
replace know_own_partyposition=0 if parti_id==6 & partyposition_DF==0
replace know_own_partyposition=0 if parti_id==7 & partyposition_V==0
replace know_own_partyposition=0 if parti_id==8 & partyposition_EL==0

replace know_own_partyposition=1 if parti_id==1 & partyposition_S==1
replace know_own_partyposition=1 if parti_id==2 & partyposition_RV==1
replace know_own_partyposition=1 if parti_id==3 & partyposition_K==1
replace know_own_partyposition=1 if parti_id==4 & partyposition_SF==1
replace know_own_partyposition=1 if parti_id==5 & partyposition_LA==1
replace know_own_partyposition=1 if parti_id==6 & partyposition_DF==1
replace know_own_partyposition=1 if parti_id==7 & partyposition_V==1
replace know_own_partyposition=1 if parti_id==8 & partyposition_EL==1

codebook know_own_partyposition
label define know_own_partyposition 0 "Don't know owns party's recommendation" 1 "Knows owns party's recommendation" 2 "Already Knew" 3 "Forgot"
label values know_own_partyposition know_own_partyposition
codebook know_own_partyposition

gen learn_partyposition=.
sort responseid timedummy
by responseid (timedummy), sort: replace learn_partyposition=0 if know_own_partyposition[_n-1]==0 & (know_own_partyposition==0)
by responseid (timedummy), sort: replace learn_partyposition=1 if know_own_partyposition[_n-1]==0 & (know_own_partyposition==1)
by responseid (timedummy), sort: replace learn_partyposition=2 if know_own_partyposition[_n-1]==1 & (know_own_partyposition==1)
by responseid (timedummy), sort: replace learn_partyposition=3 if know_own_partyposition[_n-1]==1 & (know_own_partyposition==0)
label define learn_partyposition 0 "Never Learned" 1 "Learned Party Cue" 2 "Already Knew" 3 "Forgot"
label values learn_partyposition learn_partyposition
codebook learn_partyposition

*Adding values to misssing observation regarding independent variable (learning)
bysort responseid (timedummy) : replace learn_partyposition = learn_partyposition[_n+1] if missing(learn_partyposition)

bro responseid timedummy know_own_partyposition learn_partyposition


*Generating vote_change variable used for matching analyses (for models 7 and 8)
gen vote_no_change=.
sort responseid timedummy
by responseid (timedummy), sort: replace vote_no_change=0 if vote_no[_n-1]==0 & (vote_no==0)
by responseid (timedummy), sort: replace vote_no_change=0 if vote_no[_n-1]==1 & (vote_no==1)
by responseid (timedummy), sort: replace vote_no_change=1 if vote_no[_n-1]==0 & (vote_no==1)
by responseid (timedummy), sort: replace vote_no_change=-1 if vote_no[_n-1]==1 & (vote_no==0)
label define vote_no_change 0 "Did not change vote" 1 "Changed to NO" -1 "Changed to YES"
label values vote_no_change vote_no_change
codebook vote_no_change

*Adding values to misssing observation regarding independent variable (learning)
bysort responseid (timedummy) : replace vote_no_change = vote_no_change[_n+1] if missing(vote_no_change)





**************ANALYSIS****************

*Dropping respondents who forgot policy info
drop if learn_policyinfo==3


*Figure 1
reg vote_no i.timedummy##i.learn_policyinfo, cl( responseid )
margins, over( timedummy learn_policyinfo )
marginsplot, scheme(plotplain) title("               2014 Danish Patent Court Referendum", size(large)) subtitle({it:Policy Information: Reason for Opposing}, size(medium)) xtitle("") ytitle("Proportion Voting No", size(medium)) legend(off) ylab(0(0.2)1) ylabel(0 "0%" 0.2 "20%" 0.4 "40%" 0.6 "60%" 0.8 "80%" 1 "100%", labsize(medsmall)) ciopts(recast(rspike)) xscale(r(-0.2(1.4)1.2)) xlabel(0(1)1, valuelabels nogrid labsize(medsmall)) xsize(4.5) plot1opts(mfcolor(gray)lpattern("1")msym(O)msize(medium)) plot2opts(mfcolor(black)lpattern("1")msym(O)msize(medium)) plot3opts(mfcolor(white)lpattern("1")msym(O)msize(medium)) xoverhangs text(0.0603 -0.08 "6%" 0.1408 -0.09 "14%" 0.4607 -0.09 "46%" 0.08899 1.08 "9%"  0.39799 1.1 "40%" 0.5327 1.1 "53%", size(medsmall))


*Dropping respondents who already knew policy info
drop if learn_policyinfo==2

*Creating variable that measures missing values on timevarying covariates

codebook vote_no perceived_governmentperformance followed_debate knowledge issueattitude1 issueattitude2 know_own_partyposition, tab(99)

bysort responseid ( perceived_governmentperformance ) : gen todrop1 = missing( perceived_governmentperformance [1]) | missing( perceived_governmentperformance [_N])
bro responseid timedummy perceived_governmentperformance if todrop1==1

bysort responseid ( followed_debate ) : gen todrop2 = missing( followed_debate [1]) | missing( followed_debate [_N])
bro responseid timedummy followed_debate if todrop2==1

bysort responseid ( knowledge ) : gen todrop3 = missing( knowledge [1]) | missing( knowledge [_N])
bro responseid timedummy knowledge if todrop3==1

bysort responseid ( know_own_partyposition ) : gen todrop4 = missing( know_own_partyposition [1]) | missing( know_own_partyposition [_N])
bro responseid timedummy know_own_partyposition if todrop4==1

gen missing_TV_covariates=0
replace missing_TV_covariates=1 if todrop1==1 | todrop2==1 | todrop3==1 | todrop4==1


****All voters****

*Model 1
reg vote_no i.timedummy##i.learn_policyinfo, cl(responseid)

*Model 2
reg vote_no i.timedummy##i.learn_policyinfo perceived_governmentperformance i.followed_debate knowledge i.issueattitude1 i.issueattitude2 i.know_own_partyposition if missing_TV_covariates==0, cl(responseid)

*Model 3
reg vote_no i.timedummy##(i.learn_policyinfo i.gender i.age_cat i.education i.occupation i.region)  perceived_governmentperformance i.followed_debate i.knowledge i.issueattitude1 i.issueattitude2 i.know_own_partyposition if missing_TV_covariates==0, cl(responseid)


****Voters whose party recommend voting yes (in favour of the referendum proposal)****

*Model 4
reg vote_no i.timedummy##i.learn_policyinfo if prior_partisanship==1, cl(responseid)

*Model 5
reg vote_no i.timedummy##i.learn_policyinfo perceived_governmentperformance i.followed_debate knowledge i.issueattitude1 i.issueattitude2 i.know_own_partyposition if missing_TV_covariates==0 & prior_partisanship==1, cl(responseid)

*Model 6
reg vote_no i.timedummy##(i.learn_policyinfo i.gender i.age_cat i.education i.occupation i.region)  perceived_governmentperformance i.followed_debate i.knowledge i.issueattitude1 i.issueattitude2 i.know_own_partyposition if missing_TV_covariates==0 & prior_partisanship==1, cl(responseid)



****Matched Group****
psmatch2 learn_policyinfo i.gender i.age_cat i.education i.region i.occupation prior_ideology  prior_EU_attitude if timedummy==0, out( vote_no_change ) n(1) noreplacement
bysort responseid (timedummy) : replace _weight = _weight[_n-1] if missing(_weight)

*Model 7
reg vote_no i.timedummy##i.learn_policyinfo if _weight==1, cl(responseid)

*Model 8
reg vote_no i.timedummy##i.learn_policyinfo perceived_governmentperformance i.followed_debate knowledge i.issueattitude1 i.issueattitude2 i.know_own_partyposition  if _weight==1 & missing_TV_covariates==0, cl(responseid)

